libobs_wrapper\data\properties\types/
path.rs1use getters0::Getters;
2
3use crate::{
4 data::properties::{get_enum, get_opt_str, macros::unsafe_is_of_type_result, ObsPathType},
5 run_with_obs,
6};
7
8use super::PropertyCreationInfo;
9
10#[derive(Debug, Getters, Clone)]
11#[skip_new]
12pub struct ObsPathProperty {
13 name: String,
14 description: Option<String>,
15 path_type: ObsPathType,
16 filter: String,
17 default_path: String,
18}
19
20impl TryFrom<PropertyCreationInfo> for ObsPathProperty {
21 type Error = crate::utils::ObsError;
22
23 fn try_from(
24 PropertyCreationInfo {
25 name,
26 description,
27 pointer,
28 runtime,
29 }: PropertyCreationInfo,
30 ) -> Result<Self, Self::Error> {
31 run_with_obs!(runtime, (pointer), move || {
32 unsafe_is_of_type_result!(Path, pointer)?;
33
34 let path_type = get_enum!(pointer, path_type, ObsPathType)?;
35 let filter = unsafe {
36 get_opt_str!(pointer, path_filter)
38 }
39 .unwrap_or_default();
40
41 let default_path = unsafe {
42 get_opt_str!(pointer, path_default_path)
44 }
45 .unwrap_or_default();
46 Ok(Self {
47 name,
48 description,
49 path_type,
50 filter,
51 default_path,
52 })
53 })?
54 }
55}